package 
{
	import flash.display.DisplayObject;
	import flash.display.LoaderInfo;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	/**
	 * ...
	 * @author DarkGoodWIN
	 */
	public class TGameInfo extends EventDispatcher
	{		
		public static const RES_CHANGED: String = "ResChanged";
				
		protected var Loading: TModalWindow = null;
		private var fRequestCount: int = 0;
		
		protected function StartLoading(): void
		{
			Loading = new TModalMessage("Загрузка", false);
		}

		protected function EndLoading(): void
		{
			Loading.Close();			
		}
		
		public function GoToID(ID: int, UserName: String): void
		{
			
		}

		public function AddRequest(): void
		{
			if (fRequestCount < 1)
			  StartLoading();
			++fRequestCount;
		}
		
		public function RemoveRequest(): void
		{
			--fRequestCount;
			EndLoading();
			StartLoading();
			if (fRequestCount < 1)
			  EndLoading();
		}
		
		public function ResChanged(): void
		{
			dispatchEvent(new Event(RES_CHANGED)); 
		}
				
		public function InitGame(): void
		{
		}
		
		public function getUserInfos(onComplete:Function): void
		{		
			API.APIExecute(
				'var R=API.friends.getAppUsers();' + 
			  //'var R=API.friends.get({"count": 200});' + 
			    'var Res=API.getProfiles({"uids": R, "fields": "uid,first_name,last_name,photo_medium"});' +
			    'return Res;'
				, onComplete);
		}
		
		private var API: KNVKAPI = null;
				
		public function TGameInfo(VKAPI: KNVKAPI) 
		{
			super();
			API = VKAPI;
		}
		
	}

}